<?php
require_once 'class/NHANVIEN.php';
require_once 'class/PHONGBAN.php';

if (isset($_POST['method'])) {
	$result = null;
	
	switch ($_POST['method']) {
		case 'depts':
		$result = PHONGBAN::Select();
		break;
		
		case 'search':
		$result = NHANVIEN::Search($_POST['data']);
		break;
		
		case 'create':
		$arr = (array)json_decode($_POST['data']);
		NHANVIEN::Create($arr);
		$result = $arr["MaNV"];
		break;

		case 'delete':
		$result = NHANVIEN::Delete($_POST['data']);
		break;

		case 'update':
		$arr = (array)json_decode($_POST['data']);
		$result = NHANVIEN::Update($arr);
		break;
		
		case 'deletes':
		$arr = json_decode($_POST['data']);
		$result = NHANVIEN::Deletes($arr);
		break;
	}

	header('Content-type: application/json');
	echo json_encode($result);
}
?>